﻿using System;
using System.Collections.Generic;
using AMEE.MVVMBase;

namespace AMEE.LogViewer
{
    /// <summary>
    /// A Logging Entry Instance.
    /// </summary>
    /// <remarks>
    /// PropertyChange is supported.
    /// </remarks>
    public class LogEntry : PropertyChangedBase
    {
        /// <summary>
        /// Gets or sets the time stamp.
        /// </summary>
        /// <value>
        /// The date time.
        /// </value>
        public DateTime DateTime {
            get { return _time; }
            set {
                _time = value;
                base.OnPropertyChanged("DateTime");
            }
        }
        DateTime _time;


        /// <summary>
        /// Gets or sets the index.
        /// </summary>
        /// <value>
        /// The index.
        /// </value>
        public int Index {
            get { return _idx; }
            set {
                _idx = value;
                base.OnPropertyChanged("Index");
            }
        }
        int _idx;

        /// <summary>
        /// Gets or sets the message.
        /// </summary>
        /// <value>
        /// The message (null willl be ignored).
        /// </value>
        public string Message {
            get { return _msg; }
            set {
                if (_msg != null) {
                    _msg = value;
                    base.OnPropertyChanged("Index");
                }
            }
        }
        string _msg = String.Empty;
    }



    /// <summary>
    /// A LogEntry with other Entries embedded
    /// </summary>
    public class CollapsibleLogEntry : LogEntry
    {
        /// <summary>
        /// Gets or sets the contents, not null.
        /// </summary>
        /// <value>
        /// The contents (null willl be ignored).
        /// </value>
        public List<LogEntry> Contents {
            get { return _list; }
            set {
                if (_list != null) {
                    _list = value;
                    base.OnPropertyChanged("Index");
                }
            }
        }
        List<LogEntry> _list = new List<LogEntry>();
    }
}
